﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace CodeRepositoryConsole.FCL.XML
{
    public class XMLLinq
    {

        /// <summary>
        /// <seealso cref="https://stackoverflow.com/questions/3259583/how-to-get-files-in-a-relative-path-in-c-sharp"/>
        /// </summary>
        public void Query()
        {
            // A single dot (.) can stand in for the current directory. Two dots (..) mean the parent of the current directory
            XDocument xdoc = XDocument.Load("./Data/logisticsCompany.xml");

            var query = from company in xdoc.Descendants("logistics_company")
                        select new
                        {
                            name = company.Element("name").Value,
                            code = company.Element("code").Value
                        };

            string str = "";

            foreach (var company in query)
            {
                //<ExpName>UEQ</ExpName><ExpCode>UEQ</ExpCode>
                str += "<ExpName>" + company.name + "</ExpName><ExpCode>" + company.code + "</ExpCode>" + "\n";
            }

        }
    }
}
